import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'
import { post } from '../../service/api'
import './index.scss'



class Company extends Component {
  constructor() {
    super(...arguments)
    this.state = {
      cardInfo: []
    }
  }
  config = {
    navigationBarTitleText: '卡片详情',
  }

  toPageVipdetail() {
    Taro.navigateTo({ url: "/pages/vipDetail/index" })
  }
  toPageShop() {
    Taro.navigateTo({ url: "/pages/storeList/index" })
  }
  toPagePublicNum() {
    Taro.navigateTo({ url: "/pages/publicNum/index" })
  }
  async cardFind() {
    const { data } = await post('vipCard/find');
    if (data.code == 0) {
      this.setState({
        cardInfo: data.vip
      })
    }
  }
  componentDidMount() {
    this.cardFind()
  }
  render() {
    const { cardInfo } = this.state
    return (
      <View className='care-detail'>
        <View className="my-care">
          <Image className="my-care-img" src={require('../../asset/imgs/care1.png')} />
          <View className="code">NO.{cardInfo.vipCode}</View>
        </View>
        <View className="activate-wrap">
          <Button className="activate-btn">激活您的VIP</Button>
          <View className="activate-txt">激活VIP立享家装款优惠</View>
        </View>
        <View className="atList">
          <View className="atItem" onClick={this.toPageVipdetail}>vip使用说明</View>
          <View className="atItem" onClick={this.toPageShop}>适用门店</View>
          <View className="atItem" onClick={this.toPagePublicNum}>公众号</View>
        </View>
      </View>
    )
  }
}

export default Company
